<template>
  <div>
    <el-row v-if="$store.state.edit.row.level != 1">
      <el-col :span="1">
        <el-button size="mini" type="primary" icon="print" @click="printLabel"
          >打印面单</el-button
        >
      </el-col>
    </el-row>
  </div>
</template>
<script>
import { ajax } from "@/store/yg/common/utils";
// import { print } from "@/store/yg/common/utils";
export default {
  props: ["data"],
  data() {
    return {
      id: ""
    };
  },
  methods: {
    printLabel() {
      var id = this.data.id;
      if (typeof id === "undefined" || id === null) {
        this.$message.error("打印失败,未知的记录");
        return;
      }
      var data = {};
      data["id"] = id;
      ajax("printLabel", data).then(
        res => {
          // console.log(res);
          if (res.code === 200) {
            // print(res.data.printName, res.data.base64, "pdf");
          } else if (res.code === 500) {
            this.$message.error(res.message);
          } else {
            this.$message.error("打印失败");
          }
        },
        error => {
          this.$message.error(error);
        }
      );
    }
  }
};
</script>
